import { createStore } from "vuex";

export default createStore({
  state: {
    getinfo: localStorage.getItem("ctyid")
      ? JSON.parse(localStorage.getItem("ctyid") as string)
      : {
          id: "440100",
          name: "广州",
        },
    tokey: localStorage.getItem("tokey")
      ? JSON.parse(localStorage.getItem("tokey") as string)
      : "",
  },
  getters: {},
  mutations: {
    returns(state, cty) {
      localStorage.setItem("ctyid", JSON.stringify(cty));
      state.getinfo = cty;
    },
    obtain(state, toke) {
      localStorage.setItem("tokey", JSON.stringify(toke));
      state.tokey = toke;
    },
  },
  actions: {},
  modules: {},
});
